package com.xiaobias.mySwitch;

public class Switch002 {

    public static void main(String[] args) {
        before();
        after();
    }

    public static void before() {
        String name = "许庶";
        String country;
        switch (name) {
            case "周瑜":
            case "许庶":
                country = "三国";
                break;
            case "项羽":
            case "刘邦":
                country = "汉朝";
                break;
            default:
                country = "未知";
        }
        System.out.println("Country: " + country);
    }

    public static void after() {
        var name = "许庶";
        String country = switch (name) {
            case "周瑜", "许庶" -> "三国";
            case "项羽", "刘邦" -> "汉朝";
            default -> "未知";
        };
        System.out.println("Country: " + country);
    }
}
